﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;


namespace MvcDemo.Control
{
    public abstract class MvcControlInput :MvcControlBase
    {
        public MvcControlInput(HtmlHelper htmlHelper)
            : base(htmlHelper)
        { 
            
        }

        /// <summary>
        /// 
        /// </summary>
        public MvcControlUsingModes UsingMode { get; set; }

        /// <summary>
        /// 输入框前说明文本显示的内容
        /// </summary>
        public string LableText { get; set; }

        private string seperator = ":";
        /// <summary>
        /// 提示和数据之间的分割符号
        /// </summary>
        public string Seperator
        {
            get { return this.seperator; }
            set { this.seperator = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="writer"></param>
        protected sealed override void WriteHtml(System.Web.UI.HtmlTextWriter writer)
        {
            TagBuilder tagDiv = new TagBuilder("div");
            tagDiv.AddCssClass("hl_div");
            tagDiv.InnerHtml= WriteLabelString();
            tagDiv.InnerHtml += InnerWriteHtml();

            string temp= tagDiv.ToString();
            writer.Write(temp);
        }

        protected abstract string InnerWriteHtml();

        private string WriteLabelString()
        {
            if (string.IsNullOrWhiteSpace(LableText))
            {
                return string.Empty;
            }
            else
            {
                TagBuilder tagLable = new TagBuilder("span");
                tagLable.AddCssClass("hl_span");
                tagLable.InnerHtml=LableText + seperator;
                return tagLable.ToString();
            }
        }
    }
}